<template>
  <div>
    <el-dialog
      title="预约详情"
      :visible.sync="appoDetailVisible"
      :destroy-on-close="true"
      width="70%"
      class="ky-dialog">
      <div class="appoDetail-wrap">
        <el-table
          :data="tableData"
          class="ky-table ky-table-sm"
          border
          v-loading="loading"
          style="width: 100%">
          <el-table-column prop="callId" label="预约号码">
            <template slot-scope="scope">
              <el-tag type="success" size="mini">{{scope.row.callId}}</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="scheduledDttm" label="预约时间" :formatter="dttmFtr" width="160"></el-table-column>
          <el-table-column prop="checkStatus" label="预约状态"></el-table-column>
          <el-table-column prop="registerDoctor" label="登记人员"></el-table-column>
          <el-table-column prop="appointmentType" label="预约来源"></el-table-column>
          <el-table-column prop="patientName" label="患者姓名"></el-table-column>
          <el-table-column prop="patientType" label="患者类型"></el-table-column>
          <el-table-column prop="triggerDate" label="触发时间" width="160"></el-table-column>
          <el-table-column prop="scheduledDep" label="检查部门"></el-table-column>
          <el-table-column prop="registerpart" label="检查部位"></el-table-column>
          <el-table-column prop="checkpos" label="检查项目" min-width="210"></el-table-column>
          <el-table-column prop="checkDoctor" label="检查医生"></el-table-column>
          <el-table-column prop="checkDttm" label="检查时间" :formatter="dttmFtr" width="160"></el-table-column>
          <el-table-column prop="checkType" label="检查类型"></el-table-column>
          <el-table-column prop="scheduledModality" label="检查设备"></el-table-column>
          <el-table-column prop="patientSex" label="患者性别"></el-table-column>
          <el-table-column prop="patientBirthDate" label="患者生日" :formatter="dttmDateFtr" width="120"></el-table-column>
          <el-table-column prop="patienMobile" label="联系方式"></el-table-column>
          <el-table-column prop="callNum" label="呼叫次数"></el-table-column>
          <el-table-column prop="firstCallDttm" label="第一次呼叫时间" :formatter="dttmFtr" width="160"></el-table-column>
          <el-table-column prop="lastCallDttm" label="最后一次呼叫时间" :formatter="dttmFtr" width="160"></el-table-column>
        </el-table>
        <paginationCont
          :total="totalCount"
          :page.sync="currentPage"
          :limit.sync="pageSize"
          @pagination="getlist"
        />
      </div>
      <!-- <span slot="footer" class="">
        <el-button size="mini" @click="appoDetailVisible = false">关闭</el-button>
      </span> -->
    </el-dialog>
  </div>
</template>

<script>
import { getpagesbyappointmentlistdmb } from '@/api/api'
import paginationCont from '@/components/Pagination/index'
export default {
  components: { paginationCont },
  data() {
    return {
      // 预约详情
      appoDetailVisible: false,
      loading: false,
      totalCount: 0,
      pageSize: 10,
      currentPage: 1,
      formdata: {
        HospitalCode: ''
      },
      tableData: []
    }
  },
  methods: {
    init(data) {
      // console.log('appoInfoDetail:===', data)
      this.appoDetailVisible = true
      this.formdata = Object.assign(this.formdata, data)
      this.search()
    },
    search() {
      this.currentPage = 1
      this.getlist()
    },
    // 获取预约详情
    getlist() {
      const params = {
        ...this.formdata,
        pageNumber: this.currentPage,
        pageSize: this.pageSize,
        SortName: 'CallRegisterKey'
      }
      this.loading = true
      getpagesbyappointmentlistdmb(params).then(res => {
        this.loading = false
        if (res && res.code === 10000) {
          this.tableData = res.content.list
          this.totalCount = res.content.totalCount
        }
      })
    },
    dttmFtr(a, b, val) {
      return val ? (val + '').replace(/(.{4})(.{2})(.{2})(.{2})(.{2})(.{2})/, '$1-$2-$3 $4:$5:$6') : ''
    },
    dttmDateFtr(a, b, val) {
      return val ? (val + '').replace(/(.{4})(.{2})(.{2})/, '$1-$2-$3') : ''
    }
  }
}
</script>

<style lang="scss" scoped>
.appoDetail-wrap{
  padding: 15px 15px 0;
  .page_wrap{
    text-align: left;
  }
}
</style>
